using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

using Microsoft.ConnectionEngine.Registers.Core.ServiceProvider.Common;
using Microsoft.ConnectionEngine.Registers.Core.ServiceProvider.Common.DataSets;

using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Configuration;

namespace Microsoft.ConnectionEngine.Registers.Core.ServiceProvider.DataAccess
{
    public class ServiceProviderPool
    {

        #region Get/Search Methods

        /// <summary>
        /// Returns true if a ServiceProviderPool row exists
        /// </summary>
        /// <param name="poolid"></param>
        /// <param name="serviceproviderid"></param>
        /// <returns>True if successful</returns>
        public static bool ServiceProviderPoolExists(string poolID, string serviceProviderID)
        {
            bool result = false;
            string SQL = "ServiceProviderPoolExists";

            Database db = DatabaseFactory.CreateDatabase(DataAccessHelper.GetDefaultConnectionStringName());
            if (Convert.ToInt32(db.ExecuteScalar(SQL, poolID, serviceProviderID)) > 0)
                result = true;

            return result;
        }

        #endregion
        
        #region Insert Methods

        /// <summary>
        /// Inserts a new ServiceProviderPool
        /// </summary>
        /// <param name="poolid"></param>
        /// <param name="serviceproviderid"></param>
        /// <returns>A new ID if successful, otherwise empty string</returns>
        public static bool ServiceProviderPoolInsert(string poolID, string serviceProviderID)
        {
            bool result = true;
            string SQL = "ServiceProviderPoolInsert";

            Database db = DatabaseFactory.CreateDatabase(DataAccessHelper.GetDefaultConnectionStringName());
            if (db.ExecuteNonQuery(SQL, poolID, serviceProviderID) <= 0)
                result = false;

            return result;
        }

        #endregion

        #region Delete Methods
        
        /// <summary>
        /// Deletes a service provider pool
        /// </summary>
        /// <param name="poolid"></param>
        /// <param name="serviceproviderid"></param>
        /// <returns>True if successful</returns>
        public static bool ServiceProviderPoolDelete(string poolID, string serviceProviderID)
        {
            bool result = true;
            string SQL = "ServiceProviderPoolDelete";

            Database db = DatabaseFactory.CreateDatabase(DataAccessHelper.GetDefaultConnectionStringName());
            if (db.ExecuteNonQuery(SQL, poolID, serviceProviderID) <= 0)
                result = false;

            return result;
        }


        #endregion

    }
}
